package orz.xuchao.javapatterns.composite.safety;
/**
 * 安全式合成模式的结构
 * @author DragonKnight
 *
 */
public class TestSafetyComposite {

	public static void test() {
		Composite root = new Composite("服装");
		Composite c1 = new Composite("男装");
		Composite c2 = new Composite("女装");

		Leaf leaf1 = new Leaf("衬衫");
		Leaf leaf2 = new Leaf("夹克");
		Leaf leaf3 = new Leaf("裙子");
		Leaf leaf4 = new Leaf("套装");

		root.addChild(c1);
		root.addChild(c2);
		c1.addChild(leaf1);
		c1.addChild(leaf2);
		c2.addChild(leaf3);
		c2.addChild(leaf4);

		root.printStruct("");
	}
}
